package com.gitee.wsl.net.token.bean

import kotlinx.datetime.Clock
import kotlinx.datetime.DateTimeUnit
import kotlinx.datetime.Instant
import kotlinx.datetime.until

interface ExpirableToken {
    val expireTime: Instant

    fun expiresIn(): Int =
        Clock.System.now().until(expireTime, DateTimeUnit.SECOND).toInt()

    fun expired(): Boolean =
        expiresIn() <= 0
}